<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.example.simpleforum.model.Forum" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
    <title>板块搜索结果 - 极简论坛</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div class="container">
        <h1>板块搜索结果</h1>
        
        <div class="search-box">
            <form action="ForumSearchServlet" method="get">
                <input type="text" name="keyword" value="<%= request.getParameter("keyword") != null ? request.getParameter("keyword") : "" %>" placeholder="输入板块名称">
                <button type="submit">搜索</button>
            </form>
        </div>

        <div class="actions">
            <a href="PostListServlet" class="btn">返回帖子列表</a>
            <a href="index.jsp" class="btn">返回首页</a>
        </div>

        <% if (request.getParameter("keyword") != null) { %>
            <p>搜索关键词: "<%= request.getParameter("keyword") %>"</p>
        <% } %>

        <div class="forum-list">
            <% 
                List<Forum> forums = (List<Forum>) request.getAttribute("forums");
                if (forums != null && !forums.isEmpty()) {
                    for (Forum forum : forums) { 
            %>
                <div class="forum-item">
                    <h3><a href="PostListServlet?forumId=<%= forum.getId() %>"><%= forum.getName() %></a></h3>
                    <p class="description"><%= forum.getDescription() != null ? forum.getDescription() : "暂无描述" %></p>
                </div>
            <% 
                    }
                } else { 
            %>
                <p class="no-results">没有找到匹配的板块</p>
            <% } %>
        </div>
    </div>
</body>
</html>